<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>工厂模式：向函数中传入参数，就能获得想要的数据</p>

    <script>
        // 函数就是工厂 给工厂下单 就是向函数传参
        function createCar(color, paiLiang, howLong, num) {
            // 车身颜色  排量 续航 排气管数量
            var bigBen = {};
            bigBen.color = color;
            bigBen.paiLiang = paiLiang;
            bigBen.howLong = howLong;
            bigBen.num = num;

            bigBen.drive = function() {
                console.log(1);
                console.log(bigBen);
            }
            bigBen.deSpeed = function() {
                console.log('我还没上车！');
            }

            return bigBen
        }
        var car1 = createCar('red', 0.8, '400km', 1);
        var car2 = createCar('black', 2.8, '4000km', 10);
        console.log(car1 instanceof createCar);  // car1是不是createCar创建出来的一个实例
    </script>
</body>
</html>